package com.liy.framework.common.logs.pool;

import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

public class DBLogThreadPoolTaskExecutor {
    private static ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();

    public DBLogThreadPoolTaskExecutor() {
    }

    public static void execute(Runnable task) {
        taskExecutor.execute(task);
    }

    static {
        taskExecutor.setQueueCapacity(1000);
        taskExecutor.setCorePoolSize(10);
        taskExecutor.setMaxPoolSize(30);
        taskExecutor.setKeepAliveSeconds(5000);
        taskExecutor.setThreadNamePrefix("Das-DBLogs-Executor-");
        taskExecutor.setRejectedExecutionHandler(new CallerRunsPolicy());
        taskExecutor.initialize();
    }
}
